Repository navigation
[6254] 真插件完成或用户停止后无闪烁重排 AI 侧边栏内容 - #4814
Merged
PinkMagicFly merged 3 commits intoNov 26, 2026
Merged
Conversation
PinkMagicFly
deleted the
pigmagicfly/6254/sidebar-content-reflow-after-reply
branch
November 26, 2026 07:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[6254] 真插件完成或用户停止后无闪烁重排 AI 侧边栏内容
背景
对应任务文档:dev-agent devel/6254.stem。
Liii 真插件流式回复会多次改变消息树、列表、代码和公式的尺寸,用户主动停止时还会留下被截断但仍需完整排版的最终消息树。正常结束和主动停止都应在宿主状态稳定后重新计算内容布局,否则停止后的部分回答仍可能保留流式过程中的不理想尺寸。
手动重新打开侧边栏能刷新排版,但把这一动作直接自动化会产生不可接受的视觉闪烁和状态副作用(Dock 消失再出现、onDockSidebarShown 可能把翻译/释义专属会话切到新会话)。本 PR 只复用其最终布局效果,不复用整个 Dock 的显隐过程。
改动
宿主调度(qt_chat_controller)
qt-chat-tab-notify-real-plugin-completed(string)(src/Scheme/L5/glue_qt.lua),由 Liiifinalize-response!在data-end后经flush-command投递,携带本轮 sessionId。requestConversationReflow(sessionId, reason):按 sessionId 维护轻量待重排状态reflowPending_。同一会话已有待执行任务时合并,只执行一次;Generating 时只登记,等 idle 收尾后调度;Idle 时立即经QTimer::singleShot(0,...)调度,避免重入插件回调栈和正在清理的控件。notifyStateChanged的 idle 分支在现有收尾(exportBuffer/updateManifest/focusInput)后调度 pending 重排。onCancelRequested先登记 Stop 重排再call("chat-tab-cancel"):进程停止后不再依赖插件补发完成通知。onSendRequested置 Generating 时清除该 sid 的 pending:用户迅速开始新一轮时取消旧的待执行重排,不在新一轮流式输出中重排。executeReflow:清除 pending 后校验会话/面板仍在、非 Generating、AI Dock 可见且 panel 是当前活动面板(后台会话不抢焦点),再委托 View 重排;任一条件不满足则跳过。视图重排(qt_chat_tab_widget)
QTChatTabWidget::reflowConversationContent(panel):同一 Qt 事件回调内同步完成 ——setUpdatesEnabled(false)(作用域守卫保证恢复)→conversationStack_移除并立即重新插入同一 panel 指针、恢复当前面板 → panel/消息区/嵌入编辑器布局invalidate/activate/updateGeometry→ 恢复焦点与消息滚动位置。中间不 processEvents、sleep、隐藏 Dock 或跨定时器等待。ChatConversationPanel::reflowContent():对消息区容器与嵌入编辑器做同类原子重挂和尺寸重算,使 TeXmacs 消息排版按当前宽度重新计算。不改
tm-llm.scm不修改;公共chat-tab-session-next不新增完成重排触发;普通 idle 不一律重排。测试
非 GUI 单元测试(不弹窗),覆盖调度、合并去重、推迟、取消、门控、布局重算:
控制器测试要点:正常完成在 Generating 先登记、idle 收尾后只调度一次;通知晚于 idle 也能调度一次;重复 idle、未知 sessionId、已删除面板不重排不崩溃;用户 Stop 登记、idle 后消费一次;正常完成与 Stop 竞态合并为一次;新一轮取消旧待执行重排;后台会话/未可见 Dock 跳过。
视图测试要点:重挂同一 panel 指针、活动面板不变;非活动面板跳过;
conversationReflowed信号发射;null panel 安全;reflowLayoutOps布局重算计数递增。待手动 GUI 验收(未自动执行)
按任务文档 3.1 四项在真实 GUI 中执行(本 PR 不自动驱动 GUI):
关联